class MarketFlyWeight:
    """股市享元类"""
    def __init__(self, name):
        self.name = name

    def buy(self):
        print("我在" + self.name + "购买股票")

    def info(self):
        print("我在" + self.name + "查看股市信息")
        
class MarketFactory:
    """股市创建工厂"""
    def __init__(self):
        self.market = {}

    def get_market(self, market_name):
        market = self.market.get(market_name)
        if market:
            print("我们正在共享" + market_name)
            return market
        market = MarketFlyWeight(market_name)
        self.market[market_name] = market
        return market
if __name__ == "__main__":
    factory = MarketFactory()
    A_market = factory.get_market("A股")
    G_market = factory.get_market("港股")
    A_market.info()
    G_market.info()
    AC_market = factory.get_market("A股")
    AC_market.info()